package org.kl.auditsupervision.service.fnd;

 

import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.kl.auditsupervision.entity.fnd.CleanRisk;
import org.kl.auditsupervision.repository.fnd.CleanRiskDao;
import org.kl.bf.service.BasicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestParam;
import org.springside.modules.utils.Collections3;

import com.alibaba.fastjson.JSON;
/**
 * @author Code Generator
 * @since  2016-07-25 10:53:52
 * @see 廉洁风险表
 */
// Spring Bean的标识.
@Component
// 默认将类中的所有public函数纳入事务管理.
@Transactional
public class CleanRiskService extends BasicService<CleanRisk> {
	@Autowired
	private CleanRiskDao cleanRiskDao;
	
	
	
	public void save(CleanRisk entity, @RequestParam(value = "inserted") String detailInserted,
			@RequestParam(value = "updated") String detailUpdated, @RequestParam(value = "deleted") String detailDeleted) {
		cleanRiskDao.save(entity);
		if (StringUtils.isNotBlank(detailInserted)) {
			List<CleanRisk> inserts = JSON.parseArray(detailInserted, CleanRisk.class);
			if (Collections3.isNotEmpty(inserts)) {
				for (CleanRisk a : inserts) {
					// 增加与主表相关的数据复制代码
					cleanRiskDao.save(a);
				}
			}
		}
		if (StringUtils.isNotBlank(detailUpdated)) {
			List<CleanRisk> updates = JSON.parseArray(detailUpdated, CleanRisk.class);
			if (Collections3.isNotEmpty(updates)) {
				for (CleanRisk b : updates) {
					cleanRiskDao.save(b);
				}
			}
		}
		if (StringUtils.isNotBlank(detailDeleted)) {
			List<CleanRisk> deletes = JSON.parseArray(detailDeleted, CleanRisk.class);
			if (Collections3.isNotEmpty(deletes)) {
				cleanRiskDao.delete(deletes);
			}
		}
	}
}
